package com.icss.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.icss.feign.model.User;
import com.icss.service.dao.UserDAO;
import com.icss.service.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/* 用户服务实现类*/
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDAO userDAO;

    @Override
    public Integer register(User user) {
        return userDAO.insert(user);
    }

    @Override
    public User queryByAccount(String account) {
        return userDAO.selectOne(new QueryWrapper<User>().eq("user_name",account));
    }

    @Override
    public void updateUserState(int userId) {
        User user = userDAO.selectById(userId);
        if(user != null) {
           // Integer user_state = user.getUser_state();
           // user_state=  user_state>0?0: 1;//  user_state >0  则 返回 0 否则 返回 1   那么就是  0->1   或者 1->0
            user.setUser_state(1);
            userDAO.updateById(user);
        }
    }
}
